package com.albert;

import com.albert.utils.HttpClientUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

@Slf4j
public class WeChatMsg {
    public static String sendWeChatMsg(){
        String url = "http://hongyun.shenghongpec.com:30000/apps/supcon-wxsrv/api/WeiXin/Foreign";
        JSONObject jsonParams = new JSONObject();
        // 添加各个参数到JSONObject中
        jsonParams.put("Userid", "5413");
        jsonParams.put("Text", "这是一个对外接口测试");
        jsonParams.put("MsgType", "txt");
        jsonParams.put("MsgId", "");
        jsonParams.put("SendTimes", 0);
        jsonParams.put("Stat", "");
        JSONObject jsonHeader = new JSONObject();
        jsonHeader.put("Authorization","Bearer 16397EEDBF30418A86CE834A1D068");
        String response = null;
        try {
            response = HttpClientUtil.post(jsonHeader, url, jsonParams);
        } catch (IOException e) {
            log.info("推送消息失败");
            throw new RuntimeException(e);
        }
        System.out.println("得到返回消息:"+response);
        return "success";
    }

    public static void main(String[] args) {
        sendWeChatMsg();
    }
}
